package id.mankel.commons.function;

import java.util.function.Function;

/**
 * Normal Function: <code>Function&lt;T, R&gt; f = s -> s.length();</code>
 * <p>
 * Throwable Function: <code>(ThrowableFunction&lt;T, R&gt;) s -> s.length();</code>
 * @see org.apache.commons.lang3.function.Failable
 */
@FunctionalInterface
public interface ThrowableFunction<T, R> extends Function<T, R> {

    @Override
    default R apply(T t) {
        try {
            return this.throwableApply(t);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    R throwableApply(T T) throws Exception;

}
